#pragma once

#include "Game/Process/RenderProcess.h"
#include "Render/Texture/Picture2DTexture.h"
#include "Render/Texture/RenderTarget.h"
#include "Render/Tradition/RHIRenderPass.h"
#include "Render/Tradition/GraphicsPipeline.h"
#include "Render/Texture/ColorRenderTarget.h"
#include "Render/Texture/CubemapTexture.h"
#include "Render/Texture/DepthRenderTarget.h"
#include "Render/Shader/RHIDescriptor.h"
#include "Render/Tradition/RHIFramebuffer.h"
#include "LocalEntity.h"


class PbrProcess : public RenderProcess
{
	DECLARE_PROCESS(PbrProcess)

	struct Material {
		// Parameter block used as push constant block
		struct PushBlock {
			float roughness;
			float metallic;
			float r, g, b;
		} params;
		std::string name;
		Material() {};
		Material(std::string n, glm::vec3 c, float r, float m) : name(n) {
			params.roughness = r;
			params.metallic = m;
			params.r = c.r;
			params.g = c.g;
			params.b = c.b;
		};
	};

	struct Ubo
	{
		glm::mat4 proj;
		glm::mat4 model;
		glm::mat4 view;
		glm::vec4 camera;
	};

	struct LightUbo {
		glm::vec4 lights[4];
		glm::vec4 colors[4];
		int32 mWatchMode;
	};

protected:

	virtual void OnInit() override;

	virtual void OnTick(float deltaTime) override;

	virtual void OnResize() override;

public:

	std::vector<Material> mMaterials;

	std::vector<const char*> mMaterialNames;

	std::vector<const char*> mObjectNames;

	int32 mMaterialIndex;

	int32 mObjectIndex;

	int32 mWatchMode;

	std::unordered_map<std::string, LocalEntity*> mObjectEntitys;

	std::vector<LocalEntity*> mLightEntitys;

protected:
	
	RefCountPtr<RHIBuffer> mLightBuffer;

	RefCountPtr<RHIDescriptor> mDescriptor;

	RefCountPtr<GraphicsPipeline> mPipeline;
};
